package com.atguigu.member.web;

import com.alibaba.fastjson.JSON;
import com.atguigu.common.utils.R;
import com.atguigu.member.feign.OrderFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;

/**
 * description: MemberWebController
 * date: 2023/1/1 18:46
 * author: MR.孙
 */
@Controller
public class MemberWebController {

    @Autowired
    private OrderFeignService orderFeignService;

    @GetMapping("/memberOrder.html")
    public String memberOrder(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, Model model){
        //获取到支付宝给我们传来的所有请求数据
        //request。验证签名，如果正确可以去修改订单状态

        HashMap<String, Object> params = new HashMap<>();
        params.put("page", pageNum.toString());

        //查询当前登录用户的所有订单列表数据
        R r = orderFeignService.listWithItem(params);
        System.out.println(JSON.toJSONString(r));
        model.addAttribute("orders", r);

        return "orderList";
    }

}
